package com.aplicacion.apna;


import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.util.Log;
import android.view.MotionEvent;

public class Bienvenida extends Activity {

	/**
	 * {@link Thread} who will do the splash screen animation.
	 */
	private Thread splashThread = null;
	
	/**
	 * 3's of splash screen.
	 */
	protected int splashTime = 3000;
	/**
	 * {@link Dialog} for showing the legal advice.
	 */

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.bienvenida);
		startThread();
	}

	/**
	 * Start the Splash Screen {@link Thread}.
	 */
	private void startThread() {
		splashThread = new Thread() {
			@Override
			public void run() {
				try {
					synchronized (this) {
						wait(splashTime);
						Intent i = new Intent(getBaseContext(),	MenuBueno.class);
						startActivity(i);
						finish();
					}
				} catch (InterruptedException e) {
					Log.d("SplashCreen.startThread( -->", e.toString());
				}
			}
		};
		splashThread.start();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onTouchEvent(android.view.MotionEvent)
	 */
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			synchronized (splashThread) {
				splashThread.notifyAll();
			}
		}
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onPause()
	 */
	@Override
	protected void onPause() {
		super.onPause();
		if (splashThread != null) {
			splashThread.interrupt();
		}

	}

}
